﻿using System.Collections.Generic;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Linq;

namespace ClientOverflow.DataObjects
{
    /// <summary>
    /// Question class represents the Questions table in the DB. This class is in charge of maintaining
    /// the question information and hold relations with other entities - tags, answers and votes.
    /// </summary>
    [ActiveRecord]
    public class Question : ActiveRecordLinqBase<Question>
    {
        [PrimaryKey]
        public int ID { get; set; }

        [Property]
        public string Title { get; set; }

        [Property]
        public string Content { get; set; }

        [BelongsTo]
        public User Owner { get; set; }

        [HasAndBelongsToMany(Table = "QuestionsTags", ColumnKey = "QuestionID", ColumnRef = "TagID")]
        public IList<Tag> Tags { get; set; }

        [HasMany]
        public IList<Answer> Answers { get; set; }

        [Property]
        public int? CorrectAnswerID { get; set; }

        [HasMany]
        public IList<QuestionUpVote> UpVotes { get; set; }
        
        [HasMany()]
        public IList<QuestionDownVote> DownVotes { get; set; }
    }
}